/*
 * @Description: 主要是 gulpFile 配置文件
 * @version: 0.0.1
 * @Author: 小妖怪
 * @Date: 2020-06-22 09:42:27
 * @LastEditors: Mr.小妖怪
 * @LastEditTime: 2021-10-11 09:53:26
 */
const { series, src, dest, watch } = require('gulp')
const del = require('delete');
const fs = require('fs')
const babel = require('gulp-babel')
const uglify = require('gulp-uglify')
const rename = require('gulp-rename')
async function build(cb) {
    const log = fs.readFileSync('package.json')
    console.log(log);
    await Promise.resolve('some result')

}
function clean(cb) {
    del(['output/*.js'])
    cb()
}
function streamTask() {
    del(['output/*.js'])
    return src('./src/*.js')
        .pipe(babel({
            presets: ['@babel/env']
        }))
        .pipe(dest('output/'))
        .pipe(uglify())
        .pipe(rename({ extname: '.min.js' }))
        .pipe(dest('output/'))
}
exports.build = build
exports.default = series(streamTask)
// watch('src/*.js', { delay: 500 }, series(clean, streamTask))